// app.js
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })

    // 初始化购物车数据
    // 从本地存储中获取购物车历史数据
    let hisCartList = wx.getStorageSync('cartList');
    // 更新给cartList
    this.globalData.cartList = hisCartList||[];

    let placeNames = wx.getStorageSync('placeName');
    this.globalData.placeName = placeNames||'';
  },
  globalData: {
    userInfo: null,
    cartList:[], // 购物车列表
    placeName:'' // 当前定位的城市
  }
})
